#ifndef USRAI_H
#define USRAI_H

#include "AI.h"

extern tagGame tagUsrGame;
extern ins UsrIns;
/*##########DO NOT MODIFY THE CODE ABOVE##########*/

class UsrAI:public AI
{
public:
    UsrAI(){this->id=0;}
    ~UsrAI(){}

private:
    void processData() override;
    tagInfo getInfo(){return tagUsrGame.getInfo();}
    int AddToIns(instruction ins) override
    {
        UsrIns.lock.lock();
        ins.id=UsrIns.g_id;
        UsrIns.g_id++;
        UsrIns.instructions.push(ins);
        UsrIns.lock.unlock();
        return ins.id;
    }
    void clearInsRet() override
    {
        tagUsrGame.clearInsRet();
    }
    /*##########DO NOT MODIFY THE CODE IN THE CLASS##########*/
    bool tryBuildBuilding(int buildingType, int requiredWood, int maxCount, int reqiredBuilding,int is_settler=0);
    //my function
    void init();
    void updateMap();
    double distance(int, int, int, int);
    bool cutTree(int);
    bool digStone();
    bool digGold();
    bool findFarmer(tagFarmer&, int);
    bool findIdleFarmer(tagFarmer&, int);
    bool findIdleFarmer(tagFarmer&);
    bool findIdleBoat(tagFarmer&);
    bool findFullBoat(tagFarmer&);
    bool findIdleArmy(tagArmy&, int);
    bool findSomeFarmers(vector<tagFarmer>&, int, int);
    bool findSomeFarmers(vector<int>&, int, int, int);
    bool findNearbyFarmer(int, int, tagFarmer&, int);
    bool findNearbyArea(int, int, int&, int&, int&);
    bool findNearbyArmy(int, int, tagArmy&, int);
    bool findNearbyEnemy(int, int, tagArmy&, int);
    bool findNearbyEnemy(int, int, tagArmy&);
    bool findNearbyEnemyBuilding(int, int, tagBuilding&);
    bool findNearbyResource(int, int, tagResource&, int, int);
    bool findNearbyLivingResource(int, int, tagResource&, int);
    bool findNearbyContinent(int, int, double&, double&);
    bool findNearbyUnknown(int, int, double&, double&);
    bool findNearbyUnknownSea(int, int, int&, int&);
    bool findNearbyBuilding(int, int, int, tagBuilding&);
    bool findNearbyGold(tagResource&);
    bool findNearbyWater(int, int, int&, int&);
    int  findHumanWorkingOnSomething(int, int);
    int  findHumanWorkingOnSomething(int);
    int  findHumanWorkingOnResource(int);
    bool findAvailableSpace(int, int, int&, int&, int, int);
    bool findBuilding(int, int, int, tagBuilding&);
    void findWaterSpace(int, int, int&, int&, int);
    void findWaterSpace(tagFarmer&, int&, int&);
    void findWaterSpace(tagResource&, int&, int&);
    void findGrassSpace(int, int, int&, int&, int, int);
    bool findGrassSpace(int, int, int&, int&);
    void findShore(int, int, int&, int&);
    bool feasibleHouseSpace(int, int, int);
    bool feasibleWaterSpace(int, int);
    bool feasibleWater(int, int);
    bool feasibleGrass(int, int);
    bool feasibleGrass(int, int, int);
    bool feasibleArea(int, int);
    bool feasibleHeight(int, int);
    bool feasibleSea(int, int);
    bool feasibleShore(int, int);
    bool feasibleGold(tagResource&, int&);
    bool buildDock();
    bool buildDock(tagResource&);
    bool buildHouse();
    bool buildFarm();
    bool buildWareHouse(int, int, int);
    bool buildGranary();
    bool buildMarket();
    bool buildArmyCamp();
    bool buildStable(int, int);
    bool buildRange();
    bool buildArrowTower();
    bool produceFishingBoat();
    bool produceFarmer();
    bool produceShip();
    bool produceBoat();
    bool produceClubMan();
    bool produceScout();
    bool produceBowMan();
    bool upgradeCutting();
    bool upgradeFarm();
    bool upgradeTool();
    bool upgradeInfantry();
    bool upgradeArcher();
    bool upgradeRider();
    bool upgradeStone();
    bool upgradeGold();
    bool upgradeClubMan();
    bool researchArrowTower();
    bool fishing();
    bool hunting(int);
    bool hunting();
    bool exploring();
    bool working();
    bool starting();
    bool atacking();
    bool escaping();
    bool moving();
    bool researching();
    bool helping();
    bool callFarmer();
    bool cancleFarmer();
    bool checkFarmer();
    bool checkBuildings(int);
    //
};

/*##########YOUR CODE BEGINS HERE##########*/
    
/*##########YOUR CODE ENDS HERE##########*/
#endif // USRAI_H
